import React, { Component } from 'react'
import Son from './Son'
import { Provider } from './context'

export default class Parent extends Component {
  // 实例属性
  state = {
    money: 24000000000
  }

  changeMoney = money => {
    this.setState({
      money
    })
  }

  render () {
    return (
      <div>
        Parent
        <hr />
        {/* value是固定写法，用于传值 */}
        {/* <Provider value={this.state.money}> */}
        <Provider
          value={{ money: this.state.money, callback: this.changeMoney }}
        >
          <Son />
        </Provider>
      </div>
    )
  }
}
